<template>
  <div>
    <div class="litecar">
      <p>{{xinxi.title}}</p>
    </div>
    <div class="intermediate" v-html="xinxi.text">
    </div>
    <div class="downinput">
      <p class="answer">我的答案</p>
      <textarea
        v-model="formItem.info"
        style="width: 100%;border-radius: 4px;border: solid 1px #e2e2e2; margin-top: 2px;overflow:hidden;resize:none;display:block;background:#ffffff;"
      ></textarea>
        <div style="display:flex;flex-wrap:wrap;">

        <div v-for="(item,idx) of temphone" :key="idx" class="phoned">
          <img :src="item" alt="" style="width: 150rpx;height: 150rpx;">
        </div>
        </div>

      <img src="https://hterobot-kimage.oss-cn-qingdao.aliyuncs.com/images1/personal_changephoto.png" @click="Takephoto" alt="" style="width: 100rpx; height: 100rpx;">
    </div>
    <button  @click="handleOpen2" class="qs_btns">提交</button>
  </div>
</template>
<script>
export default {
  data() {
    return {
      formItem: {
        info: "",
        imageurl: this.fileList
      },
      temphone:'',
      ID:'',
      xinxi:'',
    };
  },
  onLoad(option) {
    this.ID = option.id;
  },
  mounted(){
    this.start()
  },
  methods: {
    start(){
        const ID = this.ID
          var that = this
        wx.request({
          url: this.$interfaces.findjob+"/"+ID,
         method: "get",
         success: function(res) {
            const IDs=res.data.schoolhomeworkid
            wx.request({
              url: that.$interfaces.Jobdetails+"/"+IDs,
        method: "get",
        success: function(res) {
          console.log(res)
          that.xinxi=res.data
        }
      })
       const schoolhomeworkid = res.data.schoolhomeworkid
      const type ='已接收'
       wx.request({
         url: that.$interfaces.Jobstatu+"/"+schoolhomeworkid+"/"+type,
        method: "get",
        success: function(res) {
          console.log(res)
        }
       })
         }
        })
    },
    handleOpen2(){
      console.log(123)
    },
    Takephoto(){
     var self =this
      wx.showActionSheet({
        itemList: ["从手机相册选择", "拍照"],
        success: function(res) {
          console.log(res.tapIndex);
          if (res.tapIndex === 0) {
            wx.chooseImage({
              count: 9, // 设置最多三张
              sizeType: ["original", "compressed"],
              sourceType: ["album"],
              success(res) {
                var tempFilePaths = res.tempFilePaths;
                self.temphone=res.tempFilePaths
                console.log(res.tempFilePaths)
                console.log(self.temphone)
                // 图片预览
                // wx.previewImage({
                //   current: res.tempFilePaths[0],
                //   urls: res.tempFilePaths
                // });
              }
            });
          } else if (res.tapIndex === 1) {
             wx.chooseImage({
              count: 9, // 设置最多三张
              sizeType: ["original", "compressed"],
              sourceType: ["camera"],
              success(res) {
                var tempFilePaths = res.tempFilePaths;
                // this.temphone.push(res.tempFilePaths)
                // console.log(res.tempFilePaths[0])
                // 图片预览
                // wx.previewImage({
                //   current: res.tempFilePaths[0],
                //   urls: res.tempFilePaths
                // });
              }
            });
          }
        },
        fail: function(res) {
          console.log(res.errMsg);
        }
      });
    }
  }
};
</script>
<style>
.litecar {
  padding: 20rpx;
  border-bottom: 1rpx solid black;
}
.intermediate {
  margin: 30rpx;
  background-color: #eff0f2;
  min-height: 250rpx;
  margin-bottom: 20rpx;
}
.downinput {
  padding: 20rpx;
  background-color: #eff0f2;
  margin-bottom: 20rpx;
}
.answer {
  color: red;
}
  .qs_btns {
  top: 90%;
  width: 80%;
  background: #0099FF;
  color: #fff;
  border-radius: 5px;
}
.phoned{
 flex: 30%;
}
</style>
